package com.yanqu.road.server.cmd.activity.apprentice;

import com.yanqu.road.entity.activity.apprentice.data.ApprenticeUserData;
import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ApprenticeProto;
import com.yanqu.road.pb.activity.HsIslandProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.apprentice.ApprenticeModule;
import com.yanqu.road.server.gameplayer.module.activity.hsisland.HsIslandActivityModule;
import com.yanqu.road.server.manger.activity.apprentice.pb.ApprenticePb;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = ApprenticeProto.ApprenticeEnterActivityReqMsg.class, respMsg = ApprenticeProto.ApprenticeEnterActivityRespMsg.class)
@Cmd(code = Protocol.S_APPRENTICE_ENTER_ACTIVITY,desc = "爱徒养成-进入活动")
public class ApprenticeEnterActivityCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ApprenticeProto.ApprenticeEnterActivityReqMsg reqMsg = ApprenticeProto.ApprenticeEnterActivityReqMsg.parseFrom(packet.getBytes());
        ApprenticeProto.ApprenticeEnterActivityRespMsg.Builder respMsg = ApprenticeProto.ApprenticeEnterActivityRespMsg.newBuilder();
        try {
            //进入活动
            player.getModule(ApprenticeModule.class).enterActivity(reqMsg);
        } catch (BusinessException e) {
            respMsg.setRet(e.getCode());
            player.sendPacket(Protocol.U_APPRENTICE_ENTER_ACTIVITY, respMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {}
}
